package com.wave12.pro_cart.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wave12.pro_cart.dao.ProCartDao;
import com.wave12.pro_cart.entity.ProCart;
import com.wave12.pro_cart.service.ProCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @Auther: blackcat
 * @Date: 2021-06-08
 * @Description: com.wave12.pro_cart.service.impl
 * @version:
 */
@Service
public class ProCartServiceImpl extends BaseServiceImpl<ProCart>  implements ProCartService {
    @Autowired
    ProCartDao proCartDao;
    
    @Override
    protected Mapper<ProCart> getMapper() {
        return this.proCartDao;
    }
    
    @Override
    public PageInfo<ProCart> getProCartList(Integer page, Integer size,Integer type) {
        PageHelper.startPage(page,size);
        ProCart proCart = new ProCart();
        proCart.setType(type);
        List<ProCart> proCarts = proCartDao.select(proCart);
        return new PageInfo<ProCart>(proCarts);
    }
    
    
    @Override
    public ProCart getProjectDetail(String userId,String id) {
        ProCart proCart = new ProCart();
        proCart.setUserId(userId);
        proCart.setId(id);
        List<ProCart> select = proCartDao.select(proCart);
        return select.get(0);
    }
    
    @Override
    public int inertProjectDetail(ProCart proCart) {
        return proCartDao.insert(proCart);
    }
}
